def entrance():
    while True:
        print("-----------------------------------------------------------------")
        print("1：加法 2：减法 3：乘法 4：除法 5：整除 6：取余 7：幂运算 8：开方 0:退出")
        print("-----------------------------------------------------------------")
        read = input("请输入整数（1-8）：")
        try:
            read = int(read)
            if read > 0 and read < 9:
                if read == 1:
                    a,b = (input("请输入加数和被加数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        print(add(a,b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 2:
                    a,b = (input("请输入被减数和减数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        print(less(a,b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 3:
                    a,b = (input("请输入乘数和被乘数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        print(mult(a,b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 4:
                    a, b = (input("请输入被除数和除数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        if b == 0:
                            print("除数b不能为0")
                            continue
                        print(exec(a, b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 5:
                    a, b = (input("请输入被除数和除数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        if b == 0:
                            print("除数b不能为0")
                            continue
                        print(divi(a, b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 6:
                    a, b = (input("请输入被除数和除数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        if b == 0:
                            print("除数b不能为0")
                            continue
                        print(rema(a, b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                elif read == 7:
                    a, b = (input("请输入底数和指数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        print(power(a, b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
                else:
                    a, b = (input("请输入幂和指数a b：").split())
                    try:
                        a = int(a)
                        b = int(b)
                        print(sqrt(a, b))
                    except ValueError as e:
                        print("传入参数类型不符，请校验!")
                        continue
            elif read == 0:
                break
            else:
                print('请输入正确的范围（1-8）：')
                continue
        except ValueError:
            print("传入参数类型不符，请校验!")
            continue

def add(a, b):
    return a + b

def less(a, b):
    return a - b

def mult(a, b):
    return a * b

def exce(a, b):
    return a / b

def divi(a, b):
    return a // b

def rema(a, b):
    return a % b

def power(a, b):
    return a ** b

def sqrt(a, b):
    return a ** (1 / b)

if __name__ == '__main__':
    entrance()